package team.seekers.hula.common.entity.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author ekin
 * @Description GOOD
 * @mood happy
 */
@Getter
public enum OrderEnum implements IEnum<Integer> {
    NOT_PAY(0, "未支付"),
    PAYED(1,  "已支付"),
    CANCEL(2,"已取消");

    private int type;

    private String name;

    OrderEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }

    @Override
    public Integer getValue() {
        return this.type;
    }

    public static OrderEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }

    public static OrderEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
    }
}
